"""
将数据转换成BIO标签
"""

import os

CUR_DIR = os.getcwd()
DATA_PATH = CUR_DIR + '/../sample_example'


class DataTransformer(object):

    def __init__(self, tag_path) -> None:
        super().__init__()
        self.tags = self.load_tag(tag_path)

    def load_tag(self, tag_path):
        tags = {}
        with open(tag_path, 'r') as rf:
            for line in rf:
                line = line.strip().split('#')
                index_b = line[0]
                index_e = line[1]
                index_tag = line[2]
                index_word = line[3]
                tags[(index_b, index_e)] = [index_tag, index_word]

    def transform(self, data_path):
        with open(data_path, 'r', encoding='GBK') as rf:
            lines = rf.readlines()
            print(lines)
            print(''.join(lines)[25:27])

        pass


if __name__ == "__main__":
    tag_path = DATA_PATH + '/21.tag'
    data_path = DATA_PATH + '/21.txt'
    transformer = DataTransformer(tag_path)
    transformer.transform(data_path)
